package com.fs.base.pojo;

import javax.persistence.Entity;
import javax.persistence.Table;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fs.base.annotation.ColumnDesc;

/**
 * @author TiddlerCJ
 * @desc 附件实体
 */
@Data@EqualsAndHashCode(callSuper=false) 
@Entity
@Table(name="s_attachment")
@NoArgsConstructor
@AllArgsConstructor
public class Attachment extends PkEntity{
	@ColumnDesc(name="所属用户")
	private String userId;
	@ColumnDesc(name="新文件名称")
	private String title;
	@ColumnDesc(name="原文件名称")
	private String original;
	@ColumnDesc(name="上传状态")
	private String state;
	@ColumnDesc(name="文件类型")
	private String type;
	@ColumnDesc(name="文件路径")
	private String url;
	@ColumnDesc(name="文件大小")
	private Long size;
	
	public static Attachment newInstance(User u,JSONObject fileJson){
		Attachment attachment = JSON.toJavaObject(fileJson, Attachment.class);
		attachment.setUserId(u.getId());
		return attachment;
	}
}
